<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>回调页面</title>
    <script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="plugins/vue/dist/vue.min.js"></script>
    <script type="text/javascript" src="plugins/axios/dist/axios.min.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
</head>
<body>
    <div id="myDiv">
        回调页面
    </div>
<script type="text/javascript">
    new Vue({
        el:"#myDiv",
        data:{},
        methods:{

        },
        mounted(){
            //获取当前地址->截取拿到token
            let str2Obj1 = str2Obj(location.href);
            let resultStr = {code: str2Obj1.code}
            console.log(resultStr)
            //向后端发出请求->免密登录/跳转绑定页面
            this.$http.post("/logininfo/login/back",resultStr)
                      .then(result=>{
                          result = result.data;
                          if(result.success){
                              alert("登录成功!");
                              let {token,loginInfo} = result.result;
                              localStorage.setItem("token",token);
                              localStorage.setItem("loginInfo",JSON.stringify(loginInfo));
                              //跳转首页
                              location.href="/index.html"
                          }
                          if(!result.success && result.message == "tobind"){
                              let {accessToken,openid} = result.result;
                              location.href = "/bind.html?accessToken="+accessToken+"&openid="+openid;
                          }


                      })
        }
    })

</script>

</body>
</html>